package com.api.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.api.dao.RequestParamsMapper;
import com.api.entity.RequestParams;
import com.api.service.RequestParamsService;

@Service
public class RequestParamsServiceImpl implements RequestParamsService{

	@Autowired
	private RequestParamsMapper requestParamsMapper;

	@Override
	@CachePut(value="api",key="#requestParams.id")
	public void add(RequestParams requestParams) {
		requestParams.preInsert();
		this.requestParamsMapper.insert(requestParams);
	}

	@Override
	@Cacheable(value="api",key="#requestParams.id")
	public RequestParams getRequestParams(RequestParams requestParams) {
		return this.requestParamsMapper.get(requestParams);
	}

	@Override
	@Cacheable(value="api",key="#id")
	public RequestParams getRequestParams(String id) {
		return this.requestParamsMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<RequestParams> getRequestParamsList(String api_id) {
		return this.requestParamsMapper.getRequestParamsList(api_id);
	}

	@Override
	@CacheEvict(value="api",key="#requestParams.id")
	public int delete(String api_Id) {
		return this.requestParamsMapper.deleteByPrimaryKey(api_Id);
	}
	

}
